import 'package:flutter/material.dart';
class StateFulGroupPage extends StatefulWidget {
  @override
  _StateFulGroupPageState createState() => _StateFulGroupPageState();
}

class _StateFulGroupPageState extends State<StateFulGroupPage> {
  var _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Statful'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: null,
        child: Icon(Icons.add),
      ),
      bottomNavigationBar: BottomNavigationBar(
          currentIndex: _currentIndex,
          onTap: (index){
            setState(() {
              _currentIndex = index;
            });
          },
          items: [
        BottomNavigationBarItem(
          icon: Icon(Icons.home,color: Colors.grey),
          activeIcon: Icon(Icons.home,color: Colors.blue),
          title: Text('首页')
        ),
        BottomNavigationBarItem(
            icon: Icon(Icons.list,color: Colors.grey),
            activeIcon: Icon(Icons.list,color: Colors.blue),
            title: Text('列表')
        ),
      ]),
      body: _currentIndex==0?
      RefreshIndicator(
        child: ListView(
          children: <Widget>[
            Text('首页面上拉刷新'),
            Image.network(
              'http://pic29.nipic.com/20130601/12122227_123051482000_2.jpg',
              width: 100.0,
              height: 100.0,
            ),
            TextField(
              //输入文本样式
              decoration: InputDecoration(
                contentPadding: EdgeInsets.fromLTRB(5, 0, 5, 0),
                hintText: '请输入',
                hintStyle: TextStyle(
                  fontSize: 15.0
                )
              ),
            ),
            Container(
              height: 100.0,
              margin: EdgeInsets.only(top: 10.0),
              decoration: BoxDecoration(
                color: Colors.lightBlueAccent
              ),
              child: PageView(
                children: <Widget>[
                  _item('Page1',Colors.deepOrange),
                  _item('Page2',Colors.deepPurple),
                  _item('Page3',Colors.blueGrey),
                ],
              ),
            ),
          ],
        ),
        onRefresh:handleRefresh,
      ):Text('列表页面'),
    );
  }

  Future<Null> handleRefresh() async{
    await Future.delayed(Duration(microseconds: 200));
    return null;
  }

  _item(String title, Color color) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.red,
      ),
      alignment: Alignment.center,
      child: Text(
        title,
        style: TextStyle(
          fontSize: 20.0,
          color: Colors.white
        ),
      ),
    );
  }
}
